﻿Public Class ClsTAccountDbAccess
    Inherits ClsBaseDbAccess

    'T_Account(23)
    'AccountCode,LastLevelCode,Level,AccountName,ShortName,FullName,
    'IfLastLevel,AccountType,YearMoney,BalanceDirection,YearCurrency,CurrencyCode,
    'IfRateAdjust,IfQuantity,QuantityUnit,YearQuantity,IfProject,IfCustomer,
    'IfDepartment,IfEmployee,MonthTransit,MonthTransitAcctCode,AbSet

    Public Sub New(ByVal s As String)
        MyBase.New(s, TABLE_NAME_T_ACCOUNT)
    End Sub

    Public Sub New(ByVal s As String, ByVal n As String)
        MyBase.New(s, n)
    End Sub

    ''' <summary>
    ''' 批量插入科目
    ''' </summary>
    ''' <param name="tmpList"></param>
    ''' <returns></returns>
    Public Function BatchInsertAcct(ByVal tmpList As List(Of ClsTAccount)) As Boolean

        Dim tmpRetBool As Boolean = True

        Try
            Dim tmpDb As ClsDbAccessMdb = GetConnection()
            Dim tmpParas(22) As OleDb.OleDbParameter

            Dim tmpSql As String = "Insert Into [" & Me.AppTableName & "] ("
            tmpSql &= "[AccountCode],[PrevLevelCode],[Level],[AccountName],[ShortName],"
            tmpSql &= "[FullName],[IfLastLevel],[AccountType],[YearMoney],[BalanceDirection],"
            tmpSql &= "[YearCurrency],[CurrencyCode],[IfRateAdjust],[IfQuantity],[QuantityUnit],"
            tmpSql &= "[YearQuantity],[IfProject],[IfCustomer],[IfDepartment],[IfEmployee],"
            tmpSql &= "[MonthTransit],[MonthTransitAcctCode],[AbSet]"
            tmpSql &= ") values("
            tmpSql &= "@AccountCode,@PrevLevelCode,@Level,@AccountName,@ShortName,"
            tmpSql &= "@FullName,@IfLastLevel,@AccountType,@YearMoney,@BalanceDirection,"
            tmpSql &= "@YearCurrency,@CurrencyCode,@IfRateAdjust,@IfQuantity,@QuantityUnit,"
            tmpSql &= "@YearQuantity,@IfProject,@IfCustomer,@IfDepartment,@IfEmployee,"
            tmpSql &= "@MonthTransit,@MonthTransitAcctCode,@AbSet"
            tmpSql &= ") "

            tmpParas(0) = New OleDb.OleDbParameter("@AccountCode", OleDb.OleDbType.VarWChar)
            tmpParas(1) = New OleDb.OleDbParameter("@PrevLevelCode", OleDb.OleDbType.VarWChar)
            tmpParas(2) = New OleDb.OleDbParameter("@Level", OleDb.OleDbType.Integer)
            tmpParas(3) = New OleDb.OleDbParameter("@AccountName", OleDb.OleDbType.VarWChar)
            tmpParas(4) = New OleDb.OleDbParameter("@ShortName", OleDb.OleDbType.VarWChar)
            tmpParas(5) = New OleDb.OleDbParameter("@FullName", OleDb.OleDbType.VarWChar)
            tmpParas(6) = New OleDb.OleDbParameter("@IfLastLevel", OleDb.OleDbType.Boolean)
            tmpParas(7) = New OleDb.OleDbParameter("@AccountType", OleDb.OleDbType.VarWChar)
            tmpParas(8) = New OleDb.OleDbParameter("@YearMoney", OleDb.OleDbType.Decimal)
            tmpParas(9) = New OleDb.OleDbParameter("@BalanceDirection", OleDb.OleDbType.VarWChar)
            tmpParas(10) = New OleDb.OleDbParameter("@YearCurrency", OleDb.OleDbType.Decimal)
            tmpParas(11) = New OleDb.OleDbParameter("@CurrencyCode", OleDb.OleDbType.VarWChar)
            tmpParas(12) = New OleDb.OleDbParameter("@IfRateAdjust", OleDb.OleDbType.Boolean)
            tmpParas(13) = New OleDb.OleDbParameter("@IfQuantity", OleDb.OleDbType.Boolean)
            tmpParas(14) = New OleDb.OleDbParameter("@QuantityUnit", OleDb.OleDbType.VarWChar)
            tmpParas(15) = New OleDb.OleDbParameter("@YearQuantity", OleDb.OleDbType.Single)
            tmpParas(16) = New OleDb.OleDbParameter("@IfProject", OleDb.OleDbType.Boolean)
            tmpParas(17) = New OleDb.OleDbParameter("@IfCustomer", OleDb.OleDbType.Boolean)
            tmpParas(18) = New OleDb.OleDbParameter("@IfDepartment", OleDb.OleDbType.Boolean)
            tmpParas(19) = New OleDb.OleDbParameter("@IfEmployee", OleDb.OleDbType.Boolean)
            tmpParas(20) = New OleDb.OleDbParameter("@MonthTransit", OleDb.OleDbType.VarWChar)
            tmpParas(21) = New OleDb.OleDbParameter("@MonthTransitAcctCode", OleDb.OleDbType.VarWChar)
            tmpParas(22) = New OleDb.OleDbParameter("@AbSet", OleDb.OleDbType.Integer)

            '打开表
            tmpDb.DbOpen()

            tmpDb.BeginTransaction()

            For Each cls As ClsTAccount In tmpList

                '准备参数值
                tmpParas(0).Value = ConvertStringDbNull(cls.AccountCode)
                tmpParas(1).Value = ConvertStringDbNull(cls.PrevLevelCode)
                tmpParas(2).Value = cls.Level
                tmpParas(3).Value = ConvertStringDbNull(cls.AccountName)
                tmpParas(4).Value = ConvertStringDbNull(cls.ShortName)
                tmpParas(5).Value = ConvertStringDbNull(cls.FullName)
                tmpParas(6).Value = cls.IfLastLevel
                tmpParas(7).Value = ConvertStringDbNull(cls.AccountType)
                tmpParas(8).Value = cls.YearMoney
                tmpParas(9).Value = ConvertStringDbNull(cls.BalanceDirection)
                tmpParas(10).Value = cls.YearCurrency
                tmpParas(11).Value = ConvertStringDbNull(cls.CurrencyCode)
                tmpParas(12).Value = cls.IfRateAdjust
                tmpParas(13).Value = cls.IfQuantity
                tmpParas(14).Value = ConvertStringDbNull(cls.QuantityUnit)
                tmpParas(15).Value = cls.YearQuantity
                tmpParas(16).Value = cls.IfProject
                tmpParas(17).Value = cls.IfCustomer
                tmpParas(18).Value = cls.IfDepartment
                tmpParas(19).Value = cls.IfEmployee
                tmpParas(20).Value = ConvertStringDbNull(cls.MonthTransit)
                tmpParas(21).Value = ConvertStringDbNull(cls.MonthTransitAcctCode)
                tmpParas(22).Value = cls.AbSet

                '执行查询 
                'If InsertAccount(tmpList.Item(i)) = 0 Then
                If tmpDb.InsertData(tmpSql, tmpParas, False) = 0 Then

                    Debug.Print("插入出错")
                    tmpRetBool = False
                    Exit For
                End If

            Next

            If tmpRetBool Then
                tmpDb.CompleteTransaction()
            Else
                tmpDb.RollBackTransaction()
            End If

            tmpDb.DbClose()

        Catch ex As OleDb.OleDbException

            mErrorCreater = "ClsTAccountDbAccess - BatchInsertAcct"
            mErrorMessage = ex.Message
            mErrorNumber = ex.ErrorCode

        End Try

        Return tmpRetBool

    End Function

    ''' <summary>
    ''' 返回指定编码的科目对象
    ''' </summary>
    ''' <param name="acct"></param>
    ''' <returns></returns>
    Public Function GetAccountByCode(ByVal acct As String) As ClsTAccount

        Dim tmpCls As ClsTAccount = Nothing

        Try
            Dim tmpDb As ClsDbAccessMdb = GetConnection()

            Dim tmpParas(0) As OleDb.OleDbParameter
            Dim tmpSql As String = "Select * from  [" & Me.AppTableName & "] "
            tmpSql &= " Where [AccountCode]=@AccountCode "

            tmpParas(0) = New OleDb.OleDbParameter("@AccountCode", OleDb.OleDbType.VarWChar)
            tmpParas(0).Value = acct

            '打开数据库
            tmpDb.DbOpen()

            '执行
            Dim tmpList As List(Of ClsTAccount) = New List(Of ClsTAccount)()
            tmpList = TryCast(ConvertRecordToClass(tmpDb.ExecuteSqlReturnDataSet(tmpSql, tmpParas)), List(Of ClsTAccount))
            If tmpList IsNot Nothing AndAlso tmpList.Count > 0 Then
                tmpCls = tmpList.Item(0)
            End If

            '关闭数据库
            tmpDb.DbClose()

        Catch ex As OleDb.OleDbException

            mErrorCreater = "ClsTAccountDbAccess - GetAccountByCode"
            mErrorMessage = ex.Message
            mErrorNumber = ex.ErrorCode

        End Try

        Return tmpCls

    End Function

    ''' <summary>
    ''' 取出所有的末级科目
    ''' </summary>
    ''' <returns>科目集合</returns>
    Public Function GetAllLastAccount() As List(Of ClsTAccount)

        Dim tmpList As List(Of ClsTAccount) = New List(Of ClsTAccount)()

        Try
            Dim tmpDb As ClsDbAccessMdb = GetConnection()
            'Dim retInt As Integer
            'Dim tmpParas(22) As OleDb.OleDbParameter
            Dim tmpSql As String = "Select * from  [" & Me.AppTableName & "] "
            tmpSql &= " Where [IfLastLevel] order by [AccountCode]"

            '打开数据库
            tmpDb.DbOpen()

            '执行
            tmpList = TryCast(ConvertRecordToClass(tmpDb.ExecuteSqlReturnDataSet(tmpSql, New OleDb.OleDbParameter() {})), List(Of ClsTAccount))

            '关闭数据库
            tmpDb.DbClose()


        Catch ex As OleDb.OleDbException

            mErrorCreater = "ClsTAccountDbAccess - InsertAccount"
            mErrorMessage = ex.Message
            mErrorNumber = ex.ErrorCode

        End Try

        Return tmpList

    End Function

    ''' <summary>
    ''' 删除科目
    ''' </summary>
    ''' <param name="cls"></param>
    ''' <returns></returns>
    Public Function DeleteAccount(ByVal cls As ClsTAccount) As Integer

        Try
            Dim tmpDb As ClsDbAccessMdb = GetConnection()
            Dim retInt As Integer
            Dim tmpParas(0) As OleDb.OleDbParameter
            Dim tmpSql As String = "Delete * from  [" & Me.AppTableName & "] "
            tmpSql &= " Where [AccountCode]=@AccountCode "

            tmpParas(0) = New OleDb.OleDbParameter("@AccountCode", OleDb.OleDbType.VarWChar)
            tmpParas(0).Value = ConvertStringDbNull(cls.AccountCode)

            '打开数据库
            tmpDb.DbOpen()

            '执行插入
            retInt = tmpDb.UpdateRecord(tmpSql, tmpParas)

            '关闭数据库
            tmpDb.DbClose()

            '返回结果
            Return retInt

        Catch ex As OleDb.OleDbException

            mErrorCreater = "ClsTAccountDbAccess - InsertAccount"
            mErrorMessage = ex.Message
            mErrorNumber = ex.ErrorCode

            Return 0
        End Try

    End Function

    ''' <summary>
    ''' 修改科目内容
    ''' </summary>
    ''' <param name="cls">ClsTAccount类对象</param>
    ''' <returns>成功则返回非0值</returns>
    Public Function UpdateAccount(ByVal cls As ClsTAccount) As Integer
        Try
            Dim tmpDb As ClsDbAccessMdb = GetConnection()
            Dim retInt As Integer
            Dim tmpParas(22) As OleDb.OleDbParameter
            Dim tmpSql As String = "update  [" & Me.AppTableName & "] Set "
            tmpSql &= "[PrevLevelCode]=@PrevLevelCode,[Level]=@Level,[AccountName]=@AccountName,"
            tmpSql &= "[ShortName]=@ShortName,[FullName]=@FullName,[IfLastLevel]=@IfLastLevel,[AccountType]=@AccountType,"
            tmpSql &= "[YearMoney]=@YearMoney,[BalanceDirection]=@BalanceDirection,[YearCurrency]=@YearCurrency,"
            tmpSql &= "[CurrencyCode]=@CurrencyCode,[IfRateAdjust]=@IfRateAdjust,[IfQuantity]=@IfQuantity,"
            tmpSql &= "[QuantityUnit]=@QuantityUnit,[YearQuantity]=@YearQuantity,[IfProject]=@IfProject,"
            tmpSql &= "[IfCustomer]=@IfCustomer,[IfDepartment]=@IfDepartment,[IfEmployee]=@IfEmployee,"
            tmpSql &= "[MonthTransit]=@MonthTransit,[MonthTransitAcctCode]=@MonthTransitAcctCode,[AbSet]=@AbSet "
            tmpSql &= " Where [AccountCode]=@AccountCode "

            tmpParas(0) = New OleDb.OleDbParameter("@PrevLevelCode", OleDb.OleDbType.VarWChar)
            tmpParas(1) = New OleDb.OleDbParameter("@Level", OleDb.OleDbType.Integer)
            tmpParas(2) = New OleDb.OleDbParameter("@AccountName", OleDb.OleDbType.VarWChar)
            tmpParas(3) = New OleDb.OleDbParameter("@ShortName", OleDb.OleDbType.VarWChar)
            tmpParas(4) = New OleDb.OleDbParameter("@FullName", OleDb.OleDbType.VarWChar)
            tmpParas(5) = New OleDb.OleDbParameter("@IfLastLevel", OleDb.OleDbType.Boolean)
            tmpParas(6) = New OleDb.OleDbParameter("@AccountType", OleDb.OleDbType.VarWChar)
            tmpParas(7) = New OleDb.OleDbParameter("@YearMoney", OleDb.OleDbType.Decimal)
            tmpParas(8) = New OleDb.OleDbParameter("@BalanceDirection", OleDb.OleDbType.VarWChar)
            tmpParas(9) = New OleDb.OleDbParameter("@YearCurrency", OleDb.OleDbType.Decimal)
            tmpParas(10) = New OleDb.OleDbParameter("@CurrencyCode", OleDb.OleDbType.VarWChar)
            tmpParas(11) = New OleDb.OleDbParameter("@IfRateAdjust", OleDb.OleDbType.Boolean)
            tmpParas(12) = New OleDb.OleDbParameter("@IfQuantity", OleDb.OleDbType.Boolean)
            tmpParas(13) = New OleDb.OleDbParameter("@QuantityUnit", OleDb.OleDbType.VarWChar)
            tmpParas(14) = New OleDb.OleDbParameter("@YearQuantity", OleDb.OleDbType.Single)
            tmpParas(15) = New OleDb.OleDbParameter("@IfProject", OleDb.OleDbType.Boolean)
            tmpParas(16) = New OleDb.OleDbParameter("@IfCustomer", OleDb.OleDbType.Boolean)
            tmpParas(17) = New OleDb.OleDbParameter("@IfDepartment", OleDb.OleDbType.Boolean)
            tmpParas(18) = New OleDb.OleDbParameter("@IfEmployee", OleDb.OleDbType.Boolean)
            tmpParas(19) = New OleDb.OleDbParameter("@MonthTransit", OleDb.OleDbType.VarWChar)
            tmpParas(20) = New OleDb.OleDbParameter("@MonthTransitAcctCode", OleDb.OleDbType.VarWChar)
            tmpParas(21) = New OleDb.OleDbParameter("@AbSet", OleDb.OleDbType.Integer)
            tmpParas(22) = New OleDb.OleDbParameter("@AccountCode", OleDb.OleDbType.VarWChar)

            tmpParas(0).Value = ConvertStringDbNull(cls.PrevLevelCode)
            tmpParas(1).Value = cls.Level
            tmpParas(2).Value = ConvertStringDbNull(cls.AccountName)
            tmpParas(3).Value = ConvertStringDbNull(cls.ShortName)
            tmpParas(4).Value = ConvertStringDbNull(cls.FullName)
            tmpParas(5).Value = cls.IfLastLevel
            tmpParas(6).Value = ConvertStringDbNull(cls.AccountType)
            tmpParas(7).Value = cls.YearMoney
            tmpParas(8).Value = ConvertStringDbNull(cls.BalanceDirection)
            tmpParas(9).Value = cls.YearCurrency
            tmpParas(10).Value = ConvertStringDbNull(cls.CurrencyCode)
            tmpParas(11).Value = cls.IfRateAdjust
            tmpParas(12).Value = cls.IfQuantity
            tmpParas(13).Value = ConvertStringDbNull(cls.QuantityUnit)
            tmpParas(14).Value = cls.YearQuantity
            tmpParas(15).Value = cls.IfProject
            tmpParas(16).Value = cls.IfCustomer
            tmpParas(17).Value = cls.IfDepartment
            tmpParas(18).Value = cls.IfEmployee
            tmpParas(19).Value = ConvertStringDbNull(cls.MonthTransit)
            tmpParas(20).Value = ConvertStringDbNull(cls.MonthTransitAcctCode)
            tmpParas(21).Value = cls.AbSet
            tmpParas(22).Value = ConvertStringDbNull(cls.AccountCode)

            '打开数据库
            tmpDb.DbOpen()

            '执行插入
            retInt = tmpDb.UpdateRecord(tmpSql, tmpParas)

            '关闭数据库
            tmpDb.DbClose()

            '返回结果
            Return retInt

        Catch ex As OleDb.OleDbException

            mErrorCreater = "ClsTAccountDbAccess - InsertAccount"
            mErrorMessage = ex.Message
            mErrorNumber = ex.ErrorCode

            Return 0
        End Try
    End Function

    Public Function InsertAccount(ByVal cls As ClsTAccount) As Integer

        Try
            Dim tmpDb As ClsDbAccessMdb = GetConnection()
            Dim retInt As Integer
            Dim tmpParas(22) As OleDb.OleDbParameter
            Dim tmpSql As String = "Insert Into [" & Me.AppTableName & "] ("
            tmpSql &= "[AccountCode],[PrevLevelCode],[Level],[AccountName],[ShortName],"
            tmpSql &= "[FullName],[IfLastLevel],[AccountType],[YearMoney],[BalanceDirection],"
            tmpSql &= "[YearCurrency],[CurrencyCode],[IfRateAdjust],[IfQuantity],[QuantityUnit],"
            tmpSql &= "[YearQuantity],[IfProject],[IfCustomer],[IfDepartment],[IfEmployee],"
            tmpSql &= "[MonthTransit],[MonthTransitAcctCode],[AbSet]"
            tmpSql &= ") values("
            tmpSql &= "@AccountCode,@PrevLevelCode,@Level,@AccountName,@ShortName,"
            tmpSql &= "@FullName,@IfLastLevel,@AccountType,@YearMoney,@BalanceDirection,"
            tmpSql &= "@YearCurrency,@CurrencyCode,@IfRateAdjust,@IfQuantity,@QuantityUnit,"
            tmpSql &= "@YearQuantity,@IfProject,@IfCustomer,@IfDepartment,@IfEmployee,"
            tmpSql &= "@MonthTransit,@MonthTransitAcctCode,@AbSet"
            tmpSql &= ") "

            tmpParas(0) = New OleDb.OleDbParameter("@AccountCode", OleDb.OleDbType.VarWChar)
            tmpParas(1) = New OleDb.OleDbParameter("@PrevLevelCode", OleDb.OleDbType.VarWChar)
            tmpParas(2) = New OleDb.OleDbParameter("@Level", OleDb.OleDbType.Integer)
            tmpParas(3) = New OleDb.OleDbParameter("@AccountName", OleDb.OleDbType.VarWChar)
            tmpParas(4) = New OleDb.OleDbParameter("@ShortName", OleDb.OleDbType.VarWChar)
            tmpParas(5) = New OleDb.OleDbParameter("@FullName", OleDb.OleDbType.VarWChar)
            tmpParas(6) = New OleDb.OleDbParameter("@IfLastLevel", OleDb.OleDbType.Boolean)
            tmpParas(7) = New OleDb.OleDbParameter("@AccountType", OleDb.OleDbType.VarWChar)
            tmpParas(8) = New OleDb.OleDbParameter("@YearMoney", OleDb.OleDbType.Decimal)
            tmpParas(9) = New OleDb.OleDbParameter("@BalanceDirection", OleDb.OleDbType.VarWChar)
            tmpParas(10) = New OleDb.OleDbParameter("@YearCurrency", OleDb.OleDbType.Decimal)
            tmpParas(11) = New OleDb.OleDbParameter("@CurrencyCode", OleDb.OleDbType.VarWChar)
            tmpParas(12) = New OleDb.OleDbParameter("@IfRateAdjust", OleDb.OleDbType.Boolean)
            tmpParas(13) = New OleDb.OleDbParameter("@IfQuantity", OleDb.OleDbType.Boolean)
            tmpParas(14) = New OleDb.OleDbParameter("@QuantityUnit", OleDb.OleDbType.VarWChar)
            tmpParas(15) = New OleDb.OleDbParameter("@YearQuantity", OleDb.OleDbType.Single)
            tmpParas(16) = New OleDb.OleDbParameter("@IfProject", OleDb.OleDbType.Boolean)
            tmpParas(17) = New OleDb.OleDbParameter("@IfCustomer", OleDb.OleDbType.Boolean)
            tmpParas(18) = New OleDb.OleDbParameter("@IfDepartment", OleDb.OleDbType.Boolean)
            tmpParas(19) = New OleDb.OleDbParameter("@IfEmployee", OleDb.OleDbType.Boolean)
            tmpParas(20) = New OleDb.OleDbParameter("@MonthTransit", OleDb.OleDbType.VarWChar)
            tmpParas(21) = New OleDb.OleDbParameter("@MonthTransitAcctCode", OleDb.OleDbType.VarWChar)
            tmpParas(22) = New OleDb.OleDbParameter("@AbSet", OleDb.OleDbType.Integer)

            tmpParas(0).Value = ConvertStringDbNull(cls.AccountCode)
            tmpParas(1).Value = ConvertStringDbNull(cls.PrevLevelCode)
            tmpParas(2).Value = cls.Level
            tmpParas(3).Value = ConvertStringDbNull(cls.AccountName)
            tmpParas(4).Value = ConvertStringDbNull(cls.ShortName)
            tmpParas(5).Value = ConvertStringDbNull(cls.FullName)
            tmpParas(6).Value = cls.IfLastLevel
            tmpParas(7).Value = ConvertStringDbNull(cls.AccountType)
            tmpParas(8).Value = cls.YearMoney
            tmpParas(9).Value = ConvertStringDbNull(cls.BalanceDirection)
            tmpParas(10).Value = cls.YearCurrency
            tmpParas(11).Value = ConvertStringDbNull(cls.CurrencyCode)
            tmpParas(12).Value = cls.IfRateAdjust
            tmpParas(13).Value = cls.IfQuantity
            tmpParas(14).Value = ConvertStringDbNull(cls.QuantityUnit)
            tmpParas(15).Value = cls.YearQuantity
            tmpParas(16).Value = cls.IfProject
            tmpParas(17).Value = cls.IfCustomer
            tmpParas(18).Value = cls.IfDepartment
            tmpParas(19).Value = cls.IfEmployee
            tmpParas(20).Value = ConvertStringDbNull(cls.MonthTransit)
            tmpParas(21).Value = ConvertStringDbNull(cls.MonthTransitAcctCode)
            tmpParas(22).Value = cls.AbSet

            '打开数据库
            tmpDb.DbOpen()

            '执行插入
            retInt = tmpDb.InsertData(tmpSql, tmpParas, False)

            '关闭数据库
            tmpDb.DbClose()

            '返回结果
            Return retInt

        Catch ex As OleDb.OleDbException

            mErrorCreater = "ClsTAccountDbAccess - InsertAccount"
            mErrorMessage = ex.Message
            mErrorNumber = ex.ErrorCode
            Debug.Print(ex.Message)
            Return 0
        End Try

    End Function

    Public Overrides Function ConvertRecordToClass(reader As OleDb.OleDbDataReader) As Object

        If reader Is Nothing Then
            Return Nothing
        End If

        Try

            Dim tmpList As List(Of ClsTAccount) = New List(Of ClsTAccount)
            Dim tmpCls As ClsTAccount

            While reader.Read()

                tmpCls = New ClsTAccount()

                With tmpCls
                    .AccountCode = reader.GetString(0)
                    .PrevLevelCode = ConvertDbNullString(reader(1))
                    .Level = reader.GetInt16(2)
                    .AccountName = reader.GetString(3)
                    .ShortName = ConvertDbNullString(reader(4))
                    .FullName = ConvertDbNullString(reader(5))
                    .IfLastLevel = reader.GetBoolean(6)
                    .AccountType = reader.GetString(7)
                    .YearMoney = reader.GetDouble(8)
                    .BalanceDirection = ConvertDbNullString(reader(9))
                    .YearCurrency = reader.GetDecimal(10)
                    .CurrencyCode = ConvertDbNullString(reader(11))
                    .IfRateAdjust = reader.GetBoolean(12)
                    .IfQuantity = reader.GetBoolean(13)
                    .QuantityUnit = ConvertDbNullString(reader(14))
                    .YearQuantity = reader.GetDouble(15)
                    .IfProject = reader.GetBoolean(16)
                    .IfCustomer = reader.GetBoolean(17)
                    .IfDepartment = reader.GetBoolean(18)
                    .IfEmployee = reader.GetBoolean(19)
                    .MonthTransit = ConvertDbNullString(reader(20))
                    .MonthTransitAcctCode = ConvertDbNullString(reader(21))
                    .AbSet = reader.GetInt16(22)

                End With

                tmpList.Add(tmpCls)

            End While

            Return tmpList

        Catch ex As Exception

            mErrorNumber = -1001
            mErrorMessage = ex.Message
            mErrorCreater = "ClsTVoucherGroupDbAccess - ConvertRecordToClass"

            Return Nothing
        End Try

    End Function

End Class
